<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .box{
      display:flex;
      justify-content: center;
      align-items: center;

      text-align:center;
      line-height:50px;
    }
    .box-text{
      display:flex;
      justify-content: center;
      align-items: center;
    }
    .ellipsis{
      overflow:hidden;
      text-overflow:ellipsis;
      white-space: nowrap;
    }
    .ellipsis2{
      overflow:hidden;
      text-overflow:ellipsis;
      display:-webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      white-space:normal!important;
      word-wrap:break-word;
    }
    .modal-wrapper{
      position:fixed;
      top:0;
      left:0;
      width:100%;
      height:100%;
      z-index:999;
      background-color:rgba(0,0,0,.4);

      display:flex;
      justify-content: center;
      align-items: center;
    }
    .modal{
      background:#fff;

      /* 未指定宽高 */
        /* 1.1 内联元素 */
          /* 1.1.1 文字水平垂直居中 多行文字 */
                /* display:inline;
                padding:0 20px; */
          /* 1.1.2 容器水平垂直居中 内联元素 */
              /* position:absolute;
              left:50%;
              top:50%;
              transform:translate(-50%, -50%); */
        /* 1.2 内联块 */

      /* 已指定宽高 */
      margin:20px 30px 20px;
      margin-top:10px 20px;
      -webkit-tap-highlight-color:transparent;
    }

   
  </style>
</head>
<body>
  <div class="modal-wrapper">
    <span class="modal">单行文字水平垂直居中</span>
  </div>
  <div class="box-text" id="box">
      <p class="ellipsis box-text" id="inner">用自己模拟的事件取代浏览器延迟后的事件用自己模拟的事件取代浏览器延迟后的事件用自己模拟的事件取代浏览器延迟后的事件</p>
      
  </div>
  <p class="ellipsis2">
      用自己模拟的事件取代浏览器延迟后的事件用自己模拟的事件取代浏览器延迟后的事件用自己模拟的事件取代浏览器延迟后的事件
  </p>
  <script>
    // 单纯判断
    if (window.requestAnimationFrame) {

    } else {

    }

    // 厂商前缀
    var requestAnimationFrame = window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame || function(fn){setTimeout(fn, 16)}
    
    requestAnimationFrame(function(){
      console.log(1)
    })

    if(e.target && /(^|\s)slider-indicator($|\s)/.test(e.target.className)){
      console.log("click")
    }


    // 图片懒加载
    var lazyLoadClass = ".lazyload-img"
    var imgArr = Array.prototype.slice.call(document.querySelectorAll(lazyLoadClass))

    lazyLoadImgs();
    var timer = null
    window.addEventListener('scroll', function(){
      clearTime(timer)
      timer = setTimeout(function(){
        lazyLoadImgs()
      }, 100)
    }, false)

    function lazyLoadImgs(){
      for(var i = 0; i < imgArr.length; i++){
        if(isInVisibleArea(imgArr[i])){
          imgArr[i].src = imgArr[i].getAttribute('data-src')
          imgArr.splice(i, 1);
          i--;
        }
      }
    }
    function isInVisibleArea(img){
      var rect = img.getBoundingClientRect()

      return rect.bottom > 0 && rect.top < window.innerHeight && rect.right > 0 && rect.left < window.innerWidth;
    }

    // 预加载
    var img = new Image()
    img.src = 'img/recomment/5.jpg';
    
  </script>
</body>
</html>